package com.example.myenglishbook.viewModel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

import com.example.myenglishbook.database.Words;
import com.example.myenglishbook.database.WordsRepository;

import java.util.List;

public class WordsViewModel extends AndroidViewModel {
    private WordsRepository wordsRepository;

    public WordsViewModel(@NonNull Application application) {
        super(application);
        wordsRepository=new WordsRepository(getApplication());
    }

    public LiveData<List<Words>> findWordsWithPatten(String patten){
        return wordsRepository.findWordsWithPatten(patten);
    }

    public LiveData<List<Words>> getData(){
        return wordsRepository.getData();
    }

    public void insert(Words... words){
        wordsRepository.insert(words);
    }

    public void update(Words... words){
        wordsRepository.update(words);
    }

    public void delete(Words... words){
        wordsRepository.delete(words);
    }

    public void clear(){
        wordsRepository.clear();
    }
}
